package com.xy.job.admin.core

import com.xy.job.core.utils.getIP
import org.springframework.beans.factory.InitializingBean
import org.springframework.beans.factory.annotation.Value
import org.springframework.stereotype.Component

@Component
class InetAddressHolder(
    @Value("\${xy-job.admin.ip:}")
    var ip: String,
    @Value("\${server.port:8080}")
    var port: Int,
) : InitializingBean {

    val address: String
        get() = "$ip:${port}"

    override fun afterPropertiesSet() {
        if (ip.isBlank()) {
            ip = getIP()
        }
    }
}